<template>
  <Transition :name="store.getAnimation.result ? 'fade' : 'none'">
    <div class="CustomLoading" v-if="loading">
      <!-- <div class="loadAnimation">
        <div class="rect1"></div>
        <div class="rect2"></div>
        <div class="rect3"></div>
        <div class="rect4"></div>
        <div class="rect5"></div>
        <div class="rect6"></div>
        <div class="rect7"></div>
        <div class="rect8"></div>
        <div class="rect9"></div>
        <div class="rect10"></div>
      </div> -->
      <div class="loadingbox">
        <img src="./Ghost.gif" style="width: 7vw" alt="" />
        <div class="text">加载中......</div>
      </div>
    </div>
  </Transition>
</template>

<script setup>
import { useThemeStore } from "@/stores/modules/theme.js";
const store = useThemeStore();
const props = defineProps({
  loading: {
    type: Boolean,
    default: false
  }
});
</script>

<style lang="less" scoped>
@keyframes stretchdelay {
  0%,
  40%,
  100% {
    transform: scaleY(1);
  }
  20% {
    transform: scaleY(2.4);
  }
}
.CustomLoading {
  width: 100%;
  height: 100%;
  position: fixed;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 2000;
  margin: 0;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transition: opacity 0.3s;
  display: flex;
  justify-content: center;
  align-content: center;
  align-items: center;
  user-select: none;
  cursor: progress;
  .loadingbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    .text {
      margin-top: 16px;
      text-align: center;
      color: transparent;
      background: linear-gradient(
        -45deg,
        #f1140d,
        #e73c7e,
        #38d523,
        #09b1f3,
        #09f3e0,
        #7609f3,
        #09f3e0,
        #a909f3,
        #09f3e0,
        #09b1f3,
        #38d523,
        #e73c7e,
        #f1140d
      );
      background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
      background-size: 400% 400%;
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-animation: Gradient 4s ease infinite;
      -moz-animation: Gradient 4s ease infinite;
      animation: Gradient 4s ease infinite;
    }
  }

  .loadAnimation {
    width: auto;
    height: auto;
    display: flex;
    justify-content: space-between;
    align-content: center;
    align-items: center;
    > div {
      width: 10px;
      height: 40px;
      background-color: #b3d8ff;
      margin: 0 6px;
      animation: stretchdelay 2s infinite;
      animation-timing-function: cubic-bezier(0.49, 0.13, 0.33, 0.8);
    }

    .rect1 {
      animation-delay: 0.1s;
    }
    .rect2 {
      animation-delay: 0.2s;
    }

    .rect3 {
      animation-delay: 0.3s;
    }

    .rect4 {
      animation-delay: 0.4s;
    }

    .rect5 {
      animation-delay: 0.5s;
    }

    .rect6 {
      animation-delay: 0.6s;
    }

    .rect7 {
      animation-delay: 0.7s;
    }

    .rect8 {
      animation-delay: 0.8s;
    }

    .rect9 {
      animation-delay: 0.9s;
    }

    .rect10 {
      animation-delay: 1s;
    }
  }
}

@keyframes Gradient {
  0% {
    background-position: 0% 0;
  }

  50% {
    background-position: 100% 0;
  }

  100% {
    background-position: 0% 0;
  }
}
</style>
